from utils.stream.folderstream import Folder
from utils.stream.stream import Stream
from utils.stream.folderstream import StatInfo
from utils.label import Label
from defs.exception import BlaIOError
import unittest
import os, struct

"""
class TestFolder(unittest.TestCase):
    def setUp(self):
        self.origpath = os.path.abspath(".")
        if self.origpath[-1] == os.sep:
            self.origpath = self.origpath[:-1]
        
    def tearDown(self):
        pass
        
    def testRead(self):
        fd = Folder(self.origpath)
        ctx = fd.read()
        filelist = ctx.split("\n")
        #print filelist
        for f in filelist:
            info = StatInfo()
            info.decode(f)
            print info["isdir"] and "d" or " ", "%12d" % info["size"], info["name"]
            
     
    def testWrite(self):
        fd = Folder(self.origpath)
        ctx = fd.read()
        filelist = ctx.split("\n")
        for f in filelist:
            info = StatInfo()
            info.decode(f)
            print info["isdir"] and "d" or " ", "%12d" % info["size"], info["name"]
        
        fd.write("CHD %s%sMML" % (self.origpath, os.sep))
        ctx = fd.read()
        filelist = ctx.split("\n")
        for f in filelist:
            info = StatInfo()
            info.decode(f)
            print info["isdir"] and "d" or " ", "%12d" % info["size"], info["name"]
            
        fd.write("CHD %s%s" % (self.origpath, os.sep))
        fd.write("CRD testcreatefolder")
        self.assertTrue(os.path.exists("%s%stestcreatefolder" % (self.origpath, os.sep)))
        fd.write("RMD testcreatefolder")
        
        
        
suite = unittest.TestLoader().loadTestsFromTestCase(TestFolder)
if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)
"""
